local modaoshu_skill = fk.CreateSkill {

  name = "modaoshu_skill",
  attached_equip = "modaoshu",

  tags = {},

}



modaoshu_skill:addEffect("active", {
  name = "modaoshu_skill",
  anim_type = "special",
  prompt = function(self, player, selected_cards, selected_targets)
    if #selected_cards > 0 then
      if Fk:getCardById(selected_cards[1]).suit == Card.Club then
        return "#archery_attack_skill"
      elseif Fk:getCardById(selected_cards[1]).suit == Card.Heart then
        return "#yanhui_skill"
      elseif Fk:getCardById(selected_cards[1]).suit == Card.Diamond then
        return "#amazing_grace_skill"
      elseif Fk:getCardById(selected_cards[1]).suit == Card.Spade then
        return "#savage_assault_skill"
      end
    end
    return ""
  end,
  target_num = 0,
  target_filter = Util.FalseFunc,
  card_num = 1,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and not Self:prohibitDiscard(Fk:getCardById(to_select)) and
        Fk:getCardById(to_select).suit ~= Card.NoSuit
  end,
  can_use = function(self, player)
    local slash = Fk:cloneCard("slash")
    return player.phase == Player.Play and
        table.find(Fk:currentRoom().alive_players, function(p1)
          if THB_Utility.withinTimesLimit(player, Player.HistoryPhase, slash, "slash", p1, slash.skill, 1) then
            return true
          end
        end) and player:usedSkillTimes(modaoshu_skill.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local card = Fk:getCardById(effect.cards[1])
    room:throwCard(effect.cards, modaoshu_skill.name, player, player)
    if card.suit == Card.Club then
      room:useCard({
        from = player,
        tos = room:getOtherPlayers(player),
        card = Fk:cloneCard("archery_attack")
      })
    elseif card.suit == Card.Spade then
      room:useCard({
        from = player,
        tos = room:getOtherPlayers(player),
        card = Fk:cloneCard("savage_assault")
      })
    elseif card.suit == Card.Diamond then
      room:useCard({
        from = player,
        tos = room.alive_players,
        card = Fk:cloneCard("amazing_grace")
      })
    elseif card.suit == Card.Heart then
      room:useCard({
        from = player,
        tos = room.alive_players,
        card = Fk:cloneCard("yanhui")
      })
    end
    player:addCardUseHistory("slash", 1)
  end,
})

return modaoshu_skill
